global infile "DataMain.dta"
global outfile "$results\Table 4"


* Create binned event dummies

use "$infile", clear

gen epre = 0 
gen eant = 0 
gen epost = 0 
replace epre = 1 if cohort == 1 & week <= -6 & dataset == 1
replace eant = 1 if cohort == 1 & week >= -4 & week <= -1 & dataset == 1
replace epost = 1 if cohort == 1 & week >= 0 & dataset == 1
replace epre = 1 if cohort == 2 & week2 <= -6 & dataset == 2
replace eant = 1 if cohort == 2 & week2 >= -4 & week2 <= -1 & dataset == 2
replace epost = 1 if cohort == 2 & week2 >= 0 & dataset == 2
replace epre = 1 if cohort == 3 & week2 <= -6 & dataset == 3
replace eant = 1 if cohort == 3 & week2 >= -4 & week2 <= -1 & dataset == 3
replace epost = 1 if cohort == 3 & week2 >= 0 & dataset == 3


* Table 4. Binned event estimates

reghdfe logwater epre eant epost, absorb(datasethome datasetweek) cluster(home)
outreg2 using "$outfile", keep(epre eant epost) nocon 2aster dec(3) word replace
reghdfe logwater epre eant epost if dataset == 1, absorb(datasethome datasetweek) cluster(home)
outreg2 using "$outfile", keep(epre eant epost) nocon 2aster dec(3) word ap
reghdfe logwater epre eant epost if dataset == 2, absorb(datasethome datasetweek) cluster(home)
outreg2 using "$outfile", keep(epre eant epost) nocon 2aster dec(3) word ap
reghdfe logwater epre eant epost if dataset == 3, absorb(datasethome datasetweek) cluster(home)
outreg2 using "$outfile", keep(epre eant epost) nocon 2aster dec(3) word ap
